package DaEr3_2;

import java.util.Scanner;

public class String1 {
    public static void main(String[] args) {
//        char l;
//        while (true){
//            System.out.println("输入一个字符，结束-----N");
//            Scanner scanner = new Scanner(System.in);
//            String next = scanner.next();
//            l=next.charAt(0);
//            System.out.println("l = " + l);
//            if (l == 'N') {
//                System.out.println("循环结束");
//                break;
//            }
//        }
        System.out.println("请输入你的合法email!");
        Scanner scanner = new Scanner(System.in);
           String email = scanner.next();
          String1.isEmail(email);
    }

    public static void isEmail(String email) {
        if (email.indexOf("@")!=-1){
            String substring = email.substring(0,email.indexOf("@"));
            if (substring.length()==0){
                System.out.println("非法email,@前面必须要有字符");
            }else {
                String substring1 = email.substring(email.indexOf("@")+1,email.length());
                if (substring1.length()==0){
                    System.out.println("非法email,@后面必须要有字符");
                }else {
                    boolean is=false;
                    for (int i = 0; i < substring1.length(); i++) {
                        if (substring1.charAt(i)=='.') {
                            is = true;
                        }
                    } if (is){
                        System.out.println("恭喜 合法");
                    }else {
                        System.out.println("非法email,没有点");
                    }
                }
            }
        }else {
            System.out.println("非法 无@");
        }
    }
}
